#ifndef TOPBAR_H
#define TOPBAR_H

#include <QFrame>
#include <QLabel>
#include <QTextEdit>

#include <QHttp>
#include <QBuffer>

#include "statusedit.h"

#define DEFAULT_CHARS   140
#define DEFAULT_ICON_SIZE   48
#define DEFAULT_ICON_SHADOW_SIZE    72
#define DEFAULT_TEXTEDIT_HEIGHT 80
#define DEFAULT_ICON    ":/images/defaultIcon.png"
#define DEFAULT_ICON_MASK0  ":/images/IconMask.png"
#define DEFAULT_ICON_MASK1  ":/images/IconMask1.png"
#define DEFAULT_ICON_MASK2  ":/images/IconMask2.png"

class TopBar : public QFrame
{
    Q_OBJECT
public:
    TopBar(QWidget *parent = 0);
    ~TopBar();
    enum IconBorder { AllRounded = 0, LTRBRounded = 1, LBRTRounded = 2, NoRounded = 3 };

    void changeIcon(const QString fileName = DEFAULT_ICON);
    void downloadIcon(const QString url);
    void changeIconBorder(TopBar::IconBorder ib = TopBar::AllRounded);
    void changeName(const QString name);
    void changeText(const QString text);
    void clearText();
    void changeWauDoing(const QString text);
    void enableStatusEdit(bool enable = true);
private:
    QLabel *userIcon;
    QLabel *userName;
    QLabel *leftChars;
    QLabel *wauDoing;
    QLabel *iconShadow;

    StatusEdit *statusEdit;

    QString style1;
    QString style2;
    QString style3;

        QHttp *http;
        int http_id;
        QBuffer *buffer;

private slots:
    void updateLeftChars();
    void keyPressed();

    void requestFinished(int id, bool error);

signals:
    void updateStyleSheet();
    void updateStatus(QString status);

};

#endif // TOPBAR_H

